#ifndef _VIDEO_V4L2_H_
#define _VIDEO_V4L2_H_

struct buffer
{
    void *start;
    size_t length;
};

class cls_video_v4l2
{
public:
    cls_video_v4l2(cls_video *p_video);
    ~cls_video_v4l2();

    int read_frame(ctx_image_data *img_data);

private:
    cls_video *video;
    int camera_fd;

    void open_device();
    void close_device();
    void init_device();   // use init mmap
    void uninit_device(); // uninit mmap
    void start_capturing();
    void stop_capturing();
    void init_mmap();

    struct buffer *buffers;
    unsigned int n_buffers;
};

#endif // _VIDEO_V4L2_H_
